import 'package:casdon/app/config/theme/theme_extention.dart';
import 'package:casdon/common/widget/custom_textfield.dart';
import 'package:flutter/material.dart';

class WifiPwdInputField extends StatefulWidget {
  final TextEditingController? controller;
  final ValueChanged<String>? onChanged;

  const WifiPwdInputField({super.key, this.controller, this.onChanged});

  @override
  State<WifiPwdInputField> createState() => _WifiPwdInputFieldState();
}

class _WifiPwdInputFieldState extends State<WifiPwdInputField> {
  bool _obscureText = true;

  void _togglePasswordVisibility() {
    setState(() {
      _obscureText = !_obscureText;
    });
  }

  @override
  Widget build(BuildContext context) {
    return CustomTextField(
      controller: widget.controller,
      onChanged: widget.onChanged,
      placeholder: '请输入WiFi密码',
      backgroundColor: context.customColorThemeNonNull.bgColorF7!,
      borderRadius: 12.0,
      leftIcon: const Icon(Icons.lock),
      rightIcon: Icon(_obscureText ? Icons.visibility_off : Icons.visibility),
      onRightIconPressed: _togglePasswordVisibility,
      obscureText: _obscureText,
      keyboardType: TextInputType.visiblePassword,
    );
  }
}
